package HomeWork.Extends_04;

public class Person {
    private String name;
    private int age;

    public Person() {
    }

    public Person(String name, int age) {
        this.name = name;
        this.age = age;
    }

    public void keepPet(Animal animal, String something){
        System.out.println("年龄为" + this.getAge() + "的" + this.getName() + "养了一只" +
                animal.getColor() + "颜色的" + animal.getAge() + "岁的宠物");
        if (animal instanceof Cat c){
            c.eat(something);
        }
        if (animal instanceof Dog d) {
            d.eat(something);
        }
    }

    /**
     * 获取
     * @return name
     */
    public String getName() {
        return name;
    }

    /**
     * 设置
     * @param name
     */
    public void setName(String name) {
        this.name = name;
    }

    /**
     * 获取
     * @return age
     */
    public int getAge() {
        return age;
    }

    /**
     * 设置
     * @param age
     */
    public void setAge(int age) {
        this.age = age;
    }

    public String toString() {
        return "Person{name = " + name + ", age = " + age + "}";
    }
}
